﻿function funCheckAll() {
    var isChecked = $("#ckbSelectAll")[0].checked;
    var checkBoxs = $(".tableSelectCheckBox");
    for (var i = 0; i < checkBoxs.length; i++) {
        checkBoxs[i].checked = isChecked;
    }
}

function getCheckedItems() {
    var checkBoxs = $(".tableSelectCheckBox");
    var checkBoxIds = new Array();
    for (var i = 0; i < checkBoxs.length; i++) {
        if (checkBoxs[i].checked) {
            checkBoxIds.push(checkBoxs[i].id.split('_')[1]);
        }
    }
    return checkBoxIds;
}
var Toast = Swal.mixin({
    //https://blog.csdn.net/weixin_26786277/article/details/119372385
    toast: true,
    position: 'toast-top',
    showConfirmButton: false,
    timer: 3000
});

function DeliverOrderReview(executeAction) {
    if (getCheckedItems().length <= 0) {
        Toast.fire({
            icon: 'error',
            title: '请勾选数据'
        })
        return;
    }
    ids = getCheckedItems().toString();
    $.ajax({
        type: "POST",
        async: false,
        cache: false,
        url: "/DeliverOrder/DeliverOrderReview",
        data: { action: executeAction, Ids: ids },
        dataType: "json",
        success: function (data) {
            if (data != null) {
                var msg = data.split(':');
                if (msg[0] == "ok") {
                    location.href = location.href;
                }
                else {
                    Toast.fire({
                        icon: 'error',
                        title: msg[1]
                    })
                }
            }
        }
    });
}

function DeliverOrderDel() {
    if (getCheckedItems().length <= 0) {
        Toast.fire({
            icon: 'error',
            title: '请勾选数据'
        })
        return;
    }
    $('#deliverOrderDel').modal('toggle')
}

//删除
function FunDeliverOrderDel() {
    ids = getCheckedItems().toString();
    $.ajax({
        type: "POST",
        async: false,
        cache: false,
        url: "/DeliverOrder/DeliverOrderDel",
        data: { Ids: ids },
        dataType: "json",
        success: function (data) {
            if (data != null) {
                var msg = data.split(':');
                if (msg[0] == "ok") {
                    location.href = location.href;
                }
                else {
                    Toast.fire({
                        icon: 'error',
                        title: msg[1]
                    })
                }
            }
        }
    });
}

function FunEdit(state, obj) {
    if (state!='1') {
        alert('该订单状态不为"未审核"，不能修改。');
        /* even.stopPropagation();*/
        /*  even.preventDefault();*/
        obj.href = '/DeliverOrder/Index';
    }
}